        

        var shallPayStore = new Ext.data.JsonStore({
			url: '/weihe/getList_shallPay',
			root: 'datas',
			fields : [{
						name:'ShallPayId',mapping:'id'
					},{
						name:'ShallPayType',mapping:'type'
					},{
						name:'ShallPayCompany',mapping:'company'
					},{
						name:'ShallPayContent',mapping:'content'
					},{
						name:'ShallPayProposer',mapping:'proposer'
					},{
				    	name:'ShallPayRcash',mapping:'rcash'
				    },{
				    	name:'ShallPayRbank',mapping:'rbank'
				    },{
				    	name:'ShallPayDcash',mapping:'dcash'
				    },{
				    	name:'ShallPayDbank',mapping:'dbank'
				    },{
     				   name:'ShallPayDate', mapping:'date',type : 'date', dateFormat:"Y-m-d"
      			  	},{
     				   name:'ShallPayEndDate', mapping:'endDate',type : 'date', dateFormat:"Y-m-d"
      			  	}],
				    baseParams : {'shallPay.type': 'local'},
					listeners :{ 
					   'beforeload':function(s,options) {
							var tag = 0;
							Ext.Ajax.request({
								url : '/weihe/getListJudge_shallPay',
								success : function(response) {
									var json = Ext.decode(response.responseText);
									if (json.deny) {
										Ext.Msg.alert('错误',json.msg);
										tag = 1;
									}
										if(tag == 1){
											return false;
										}else{
											return true;						
										}
								},
								failure : function() {
									Ext.Msg.alert('错误', '失败!');
									tag =1;
								}
							});
			   }
			}
		});
    	

shallPays = function(){
	
  return{
     
	  shallPayGrid : function(){

		var pageToolBar = new Ext.PagingToolbar({
			pageSize : 15,
			store : shallPayStore,
			displayInfo : true,
			displayMsg : '当前显示{0}-{1}条记录,共{2}条记录',
		    emptyMsg : "没有记录显示!",
		    firstText : '首页',
		    prevText : '上一页',
		    nextText : '下一页',
		    lastText : '尾页',
		    beforePageText : '第',
		    afterPageText : '页,共{0}页'
		});

	

		var rowSelectionModel = new Ext.grid.RowSelectionModel({singleSelect : true});
		
		 
	   var shallPayGrid = new Ext.grid.GridPanel({
		   id:'shallPayGrid',
		   title : '货币资金',
		   region : 'center',
		   minColumnWidth : 50,
		   tbar:["-",{
	   						text:"输入查询条件",
								handler:function(){
										shallPays.infoWin().show();
								}
	   					},"-",{
	   						text:"查看全部",
								handler:function(){
									Ext.getCmp("shallPayGrid").getStore().baseParams = {'flag': false,'shallPay.type': 'local'};
									Ext.getCmp("shallPayGrid").getStore().load({params : {start : 0, limit : 15}});
								}
	   			},"-"],
		   loadMask : {msg:'正在加载数据，请稍侯...'},
		   store : shallPayStore,
		   columns: [
		             {header : '公司名称', dataIndex : 'ShallPayCompany',renderer:function(value){
							if(value != ""){
									return value;
								}else{
									return "合计";
								}
		             }},
		             {header : '支付内容', dataIndex : 'ShallPayContent'},
		             {header : '申请人', dataIndex : 'ShallPayProposer'},
		             {header : '付款期限', dataIndex : 'ShallPayDate',sortable : true,renderer:Ext.util.Format.dateRenderer('Y年m月d日')},
		             {header : '(人民币)现金', dataIndex : 'ShallPayRcash'},
		             {header : '(人民币)银行', dataIndex : 'ShallPayRbank'},
		             {header : '(美金)现金', dataIndex : 'ShallPayDcash'},
		             {header : '(美金)银行', dataIndex : 'ShallPayDbank'}
        ],
           sm : rowSelectionModel,
           listeners :{ 
			   'rowclick':function(grid, rowIndex, event) {
			   var record = grid.getStore().getAt(rowIndex);
			   if(record.get('ShallPayContent')==""){
			   			Ext.Msg.alert('提示','不能编辑统计数据');
			   	}else{
				   Ext.getCmp("shallPayForm").form.loadRecord(record);
				   Ext.getCmp("shallPayForm").buttons[0].setText('修改');
			   	}
			   }
		},
		  viewConfig : {
		     forceFit : false
		  },
		  bbar : pageToolBar
});
		return shallPayGrid;
	},
	
	infoWin : function(){
	  	  var infoWin = new Ext.Window({
	  	  	id: 'shallPayInfo',
	        title:'待付款项查询',
	        layout: 'fit',
	        width:330,    
	        height:250,
	        modal: true,
	        draggable : false,
	        resizable: false,
	        closeAction:"close",
	        plain:true,    
	        items:[shallPays.queryForm()] 
	        
	    });  
	  		return infoWin;
	  	},
	  	
	  	queryForm : function(){
	  		
	  	 var queryForm = new Ext.form.FormPanel({
				baseCls:"x-plain",
				frame : true,
				autoHeight : true,
				labelAlign : 'right',
				labelWidth : 85,
				defaultType : 'textfield',
					defaults : {
					width : 200
				},
				items : [{
						  fieldLabel: "单位名称",
	      	    		  name: "shallPay.company"
				 	  },{
						  fieldLabel: "申请人",
	      	    		  name: "shallPay.proposer"
				 	  },{
	            		  xtype: 'datefield',
	                      fieldLabel: "开始日期",
	                      format : 'Y-m-d',
	            		  name: "shallPay.date"
					   },{
	            		  xtype: 'datefield',
	                      fieldLabel: "结束日期",
	                      format : 'Y-m-d',
	            		  name: 'shallPay.endDate'
					   }],
				buttons:[{
	        		 text:'确认',
	             	 handler:function(){
	             	 	var company = queryForm.form.findField('shallPay.company').getValue()
	             	 	var proposer = queryForm.form.findField('shallPay.proposer').getValue()
	             	 	var date = queryForm.form.findField('shallPay.date').getValue();
	             	 	var endDate = queryForm.form.findField('shallPay.endDate').getValue();
					 Ext.getCmp("shallPayGrid").getStore().baseParams = {'flag': true,'shallPay.company':company,
						 													  'shallPay.proposer':proposer,
						 													  'shallPay.date':date,
						 													  'shallPay.endDate':endDate,
						 													  'shallPay.type': 'local' };
					 Ext.getCmp("shallPayGrid").getStore().load({params : {start : 0, limit : 15}});
					 queryForm.form.reset();
	                 Ext.getCmp("shallPayInfo").close();
	              	
	              	}
	              },{
	                 text:'取消',
	                 handler:function(){
	                 	queryForm.form.reset();
	                 	Ext.getCmp("shallPayInfo").close();
	                 }
	              }]   
	        });
	        return queryForm;
	  	
	  	},
	
	
	
	shallPayForm : function(){
		var button_add = new Ext.Button({
			text : '添加',
			handler : function() {
					progressConsole();
				if(shallPayForm.form.isValid()){ 	
					if (shallPayForm.form.findField("shallPay.id").getValue() == "") {
						shallPayForm.form.submit({
						  url : '/weihe/add_shallPay',
						   success : function(form, action) {
							 if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
							 }else{
								Ext.Msg.alert('消息', action.result.msg, function() {
									   shallPayForm.form.reset();
									   Ext.getCmp("shallPayGrid").getStore().reload();
								});
							  }
						    }
					    });
					}else {
						shallPayForm.form.submit({
							  url : '/weihe/update_shallPay',
							   success : function(form, action) {
								 if (action.result.deny) {
									 Ext.Msg.alert('错误', action.result.msg);
								  }else{
									Ext.Msg.alert('消息', action.result.msg, function() {
										shallPayForm.form.reset();
										Ext.getCmp("shallPayGrid").getStore().reload();
										shallPayForm.buttons[0].setText('添加');
										
									});
								  }
							    }
						    });
					}
			}else{
				Ext.Msg.alert('提示','请输入相关内容');
			}
				}
		
			
		});

	var button_clear = new Ext.Button({
		id : 'button_clear',
		text : '清空',
		handler : function() {
			shallPayForm.form.reset();
			shallPayForm.buttons[0].setText('添加');
		}
	});

	var button_del = new Ext.Button({
		text : '删除',
		handler : function() {
			var id = shallPayForm.form.findField('shallPay.id').getValue();
			if (id == '') {
				Ext.Msg.alert('提示', '请选择需要删除的信息!');
			} else {
				progressConsole();
				Ext.Ajax.request({
					url : '/weihe/delete_shallPay',
					success : function(response) {
						var json = Ext.decode(response.responseText);
						if (json.success) {
							if (json.deny) {
								Ext.Msg.alert('消息', json.msg);
								shallPayForm.form.reset();
								shallPayForm.buttons[0].setText('添加');
							}else{
							Ext.Msg.alert('消息', json.msg, function() {
								Ext.getCmp("shallPayGrid").getStore().load({params : {start : 0, limit : 15}});
								shallPayForm.form.reset();
								shallPayForm.buttons[0].setText('添加');
							});
						}
					 }else{
							Ext.Msg.alert('消息', json.msg);
						}
					},
					failure : function() {
						Ext.Msg.alert('错误', '删除失败!');
					},
					params : 'shallPay.id=' + id
				});
			}
		}
	});

	var  shallPayForm = new Ext.form.FormPanel({
		id : 'shallPayForm',
		title : '货币资金信息',
		frame : true,
		width : 330,
		region : 'east',
		autoScroll : true,
		collapseMode :'mini',
		collapsible : true,
		labelAlign : 'right',
		labelWidth : 90,
		defaultType : 'textfield',
			defaults : {
			width : 200
		},
		items : [{  
			id:'ShallPayId',
			xtype : 'hidden',  
			name : 'shallPay.id'
		},{  
			id:'ShallPayType',
			xtype : 'hidden',
			name : 'shallPay.type',
			value: 'local'
		},{
			id:'ShallPayCompany',
			fieldLabel : '公司名称',
			name : 'shallPay.company'
		},{
			id:'ShallPayContent',
			fieldLabel : '支付内容',
			name : 'shallPay.content'
		},{
			id:'ShallPayProposer',
			fieldLabel : '申请人',
			name : 'shallPay.proposer'
		},{
			id: 'ShallPayDate',
            xtype: 'datefield',
            fieldLabel: "付款期限",
            format : 'Y-m-d',
			allowBlank:false,
            name: "shallPay.date"
		},{
			id:'ShallPayRcash',
			fieldLabel : '(人民币)现金',
			name : 'shallPay.rcash',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'ShallPayRbank',
			fieldLabel : '(人民币)银行',
			name : 'shallPay.rbank',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'ShallPayDcash',
			fieldLabel : '(美金)现金',
			name : 'shallPay.dcash',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		},{
			id:'ShallPayDbank',
			fieldLabel : '(美金)银行',
			name : 'shallPay.dbank',
			regex : /^$|^\d+(\.\d+)?$/,
		    regexText:'请输入有效的价格' 
		}],
		buttons : [button_add,button_clear,button_del]
	});
		return  shallPayForm;
	}
  }
}();








